package com.wgt.observer;

/**
 * 名字为Binary
 * Created by wgt on 2017/6/14.
 */
public class BinaryObserver extends Observer {


    /**
     * 构建时监听一个观察对象（可以将Subject抽象化）
     * @param subject
     */
    public BinaryObserver(Subject subject) {
        this.subject = subject;
        this.subject.attach(this);   //在观察对象中注册自己
    }

    @Override
    public void update() {
        System.out.println( "Binary String: "
                + Integer.toBinaryString( subject.getStatus() ) );
    }
}
